package com.ruicar.afs.cloud.manage.insurance.service.impl;

import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruicar.afs.cloud.common.core.enums.AfsEnumUtil;
import com.ruicar.afs.cloud.common.core.security.util.SecurityUtils;
import com.ruicar.afs.cloud.common.core.uid.AfsSequenceGenerator;
import com.ruicar.afs.cloud.common.modules.contract.enums.*;
import com.ruicar.afs.cloud.manage.common.service.ComAttachementFileService;
import com.ruicar.afs.cloud.manage.common.service.ManageUpcomeTasksRecordService;
import com.ruicar.afs.cloud.manage.common.util.CreatCaseNoUtil;
import com.ruicar.afs.cloud.manage.insurance.condition.ManageInsuranceInfoCondition;
import com.ruicar.afs.cloud.manage.insurance.entity.ManageInsuranceInfo;
import com.ruicar.afs.cloud.manage.insurance.entity.ManageInsuranceInfoBusiness;
import com.ruicar.afs.cloud.manage.insurance.entity.ManageInsuranceRenewInfo;
import com.ruicar.afs.cloud.manage.insurance.mapper.ManageInsuranceInfoMapper;
import com.ruicar.afs.cloud.manage.insurance.service.ManageInsuranceInfoService;
import com.ruicar.afs.cloud.manage.workflow.entity.WorkTaskCreatedInfo;
import com.ruicar.afs.cloud.manage.workflow.enums.NormalSubmitEnum;
import com.ruicar.afs.cloud.manage.workflow.enums.WorkflowTypeEnum;
import com.ruicar.afs.cloud.manage.workflow.processor.ContractWorkFlowSaveApproveInfoProcessor;
import com.ruicar.afs.cloud.manage.workflow.service.WorkTaskCreatedInfoService;
import com.ruicar.afs.cloud.manage.workflow.service.WorkflowSubmitService;
import com.ruicar.afs.cloud.manage.workflow.vo.TaskSubmitVO;
import com.ruicar.afs.cloud.workflow.api.dto.flowprocess.request.StartFlowRequest;
import com.ruicar.afs.cloud.workflow.gwt.service.WorkflowService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author xudongdong
 * @date 2020-06-12
 */
@Slf4j
@AllArgsConstructor
@Service
public class ManageInsuranceInfoServiceImpl extends ServiceImpl<ManageInsuranceInfoMapper, ManageInsuranceInfo> implements ManageInsuranceInfoService {

    private final ContractWorkFlowSaveApproveInfoProcessor saveApproveInfoProcessor;
    private final ManageUpcomeTasksRecordService manageUpcomeTasksRecordService;
    private final ComAttachementFileService comAttachementFileService;
    private WorkTaskCreatedInfoService workTaskCreatedInfoService;
    private final WorkflowSubmitService workflowSubmitService;
    private final AfsSequenceGenerator afsSequenceGenerator;
    private final WorkflowService workflowService;

    @Override
    public ManageInsuranceInfo saveInsurance(ManageInsuranceInfoCondition insuranceClaimCondition) {

        ManageInsuranceInfo manageInsuranceInfo = new ManageInsuranceInfo();
        BeanUtils.copyProperties(insuranceClaimCondition, manageInsuranceInfo);

        //获取渠道id
        JSONObject userExtInfo = SecurityUtils.getUser().getUserExtInfo();
        Long channel = (Long) userExtInfo.get(UserInfoKeyEnum.channelId.name());
        manageInsuranceInfo.setChannelId(channel);

        if (getById(insuranceClaimCondition.getId()) == null) {
            // 生成案件编号
            manageInsuranceInfo.setCaseNo(CreatCaseNoUtil.GeneratorCaseNo(ContractBusinessEnum.insurance));
            manageInsuranceInfo.setProcessStatus(ProcessStatusEnum.draft);
            manageInsuranceInfo.setApplyDate(DateUtil.date());
            manageInsuranceInfo.setApplyBy(SecurityUtils.getUser().getUserRealName());
            save(manageInsuranceInfo);
        }

        ManageInsuranceInfoBusiness manageInsuranceInfoBus = new ManageInsuranceInfoBusiness();

        //更新保险理赔信息
        if (InsuranceBusinessTypeEnum.insuranceClaim.equals(manageInsuranceInfo.getType())) {
            manageInsuranceInfoBus = insuranceClaimCondition.getClaimForm();
            manageInsuranceInfo.setBusinessSource(null);
            BeanUtils.copyProperties(manageInsuranceInfoBus, manageInsuranceInfo);
            updateById(manageInsuranceInfo);
        }

        //更新保险续保信息
        if (InsuranceBusinessTypeEnum.insuranceRenew.equals(manageInsuranceInfo.getType())) {
            ManageInsuranceRenewInfo renewInfo = insuranceClaimCondition.getJson();
            String json = JSON.toJSONString(renewInfo);
            manageInsuranceInfo.setInsureType(json);
            updateById(manageInsuranceInfo);
        }

        //更新保险批改信息
        if (InsuranceBusinessTypeEnum.insuranceChange.equals(manageInsuranceInfo.getType())) {
            manageInsuranceInfoBus = insuranceClaimCondition.getChangeForm();
            BeanUtils.copyProperties(manageInsuranceInfoBus, manageInsuranceInfo);
            updateById(manageInsuranceInfo);
        }

        //更新保险退保信息
        if (InsuranceBusinessTypeEnum.insuranceExit.equals(manageInsuranceInfo.getType())) {
            manageInsuranceInfoBus = insuranceClaimCondition.getExitForm();
            BeanUtils.copyProperties(manageInsuranceInfoBus, manageInsuranceInfo);
            updateById(manageInsuranceInfo);
        }
        return manageInsuranceInfo;
    }

    @Override
    public void submitInsurance(ManageInsuranceInfoCondition insuranceClaimCondition) {

        //获取渠道id
        ManageInsuranceInfo manageInsuranceInfo = getById(insuranceClaimCondition.getId());
        if (manageInsuranceInfo == null) {
            // 生成案件编号
            insuranceClaimCondition.setCaseNo(CreatCaseNoUtil.GeneratorCaseNo(ContractBusinessEnum.insurance));
            insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.draft);
            insuranceClaimCondition.setApplyDate(DateUtil.date());
            insuranceClaimCondition.setApplyBy(SecurityUtils.getUser().getUserRealName());
            save(insuranceClaimCondition);
        }
        //申请时间
        insuranceClaimCondition.setApplyDate(DateUtil.date());
        //来源
        ManageInsuranceInfoBusiness manageInsuranceBus = new ManageInsuranceInfoBusiness();
        //更新保险理赔信息、发起流程
        if (InsuranceBusinessTypeEnum.insuranceClaim.equals(insuranceClaimCondition.getType())) {
            if (ProcessStatusEnum.draft.equals(insuranceClaimCondition.getProcessStatus())) {
                manageInsuranceBus = insuranceClaimCondition.getClaimForm();
                BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.underReview);
                updateById(insuranceClaimCondition);
                //保存合同信息变更申请记录
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                StartFlowRequest startFlowRequest = new StartFlowRequest();
                startFlowRequest.setAfsFlowKey(AfsEnumUtil.key(WorkflowTypeEnum.INSURANCE_CLAIM));
                startFlowRequest.setBizDataId(String.valueOf(insuranceClaimCondition.getId()));
                startFlowRequest.setFlowName((StringUtils.isEmpty(insuranceClaimCondition.getContractNo()) ? "" : (insuranceClaimCondition.getContractNo()) + "-") + AfsEnumUtil.desc(WorkflowTypeEnum.INSURANCE_CLAIM));
                JSONObject cancelJson = JSONObject.parseObject(JSONObject.toJSONString(insuranceClaimCondition));
                //保存审批记录
                TaskSubmitVO vo = new TaskSubmitVO();
                vo.setBizData(cancelJson);
                workflowSubmitService.saveRecord(vo, AfsEnumUtil.desc(NormalSubmitEnum.SUGGEST_CHECK_FINAL));

                workflowService.startWorkFlow(startFlowRequest, cancelJson);
            } else if (ProcessStatusEnum.toBeRepaired.equals(manageInsuranceInfo.getProcessStatus())) {
                manageInsuranceBus = insuranceClaimCondition.getClaimForm();
                BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.repairedUnderReview);
                updateById(insuranceClaimCondition);
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                //流程审批
                TaskSubmitVO vo = new TaskSubmitVO();
                String json = JSONObject.toJSONString(insuranceClaimCondition);
                JSONObject cancelJson = JSONObject.parseObject(json);
                vo.setBizData(cancelJson);
                vo.setApprovalOperating(insuranceClaimCondition.getApprovalOperating());
                vo.setApprovalOpinion(AfsEnumUtil.desc(NormalSubmitEnum.SUGGEST_CHECK_FINAL));
                vo.setReasonType(insuranceClaimCondition.getReasonType());
                workflowSubmitService.submit(vo);
            }
        }

        //更新保险续保信息、发起流程
        if (InsuranceBusinessTypeEnum.insuranceRenew.equals(insuranceClaimCondition.getType())) {
            if (ProcessStatusEnum.draft.equals(insuranceClaimCondition.getProcessStatus())) {
                ManageInsuranceRenewInfo renewInfo = insuranceClaimCondition.getJson();
                String json = JSON.toJSONString(renewInfo);
                insuranceClaimCondition.setInsureType(json);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.underReview);
                updateById(insuranceClaimCondition);
                //保存合同信息变更申请记录
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                StartFlowRequest startFlowRequest = new StartFlowRequest();
                startFlowRequest.setAfsFlowKey(AfsEnumUtil.key(WorkflowTypeEnum.INSURANCE_REMNEW));
                startFlowRequest.setBizDataId(String.valueOf(insuranceClaimCondition.getId()));
                startFlowRequest.setFlowName((StringUtils.isEmpty(insuranceClaimCondition.getContractNo()) ? "" : (insuranceClaimCondition.getContractNo()) + "-") + AfsEnumUtil.desc(WorkflowTypeEnum.INSURANCE_REMNEW));
                JSONObject cancelJson = JSONObject.parseObject(JSONObject.toJSONString(insuranceClaimCondition));
                //保存审批记录
                TaskSubmitVO vo = new TaskSubmitVO();
                vo.setBizData(cancelJson);
                workflowSubmitService.saveRecord(vo, AfsEnumUtil.desc(NormalSubmitEnum.SUGGEST_CHECK_FINAL));

                workflowService.startWorkFlow(startFlowRequest, cancelJson);
            } else if (ProcessStatusEnum.toBeRepaired.equals(manageInsuranceInfo.getProcessStatus())) {
                ManageInsuranceRenewInfo renewInfo = insuranceClaimCondition.getJson();
                String jsons = JSON.toJSONString(renewInfo);
                insuranceClaimCondition.setInsureType(jsons);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.repairedUnderReview);
                updateById(insuranceClaimCondition);
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                //流程审批
                TaskSubmitVO vo = new TaskSubmitVO();
                String json = JSONObject.toJSONString(insuranceClaimCondition);
                JSONObject cancelJson = JSONObject.parseObject(json);
                vo.setBizData(cancelJson);
                vo.setApprovalOperating(insuranceClaimCondition.getApprovalOperating());
                vo.setApprovalOpinion(insuranceClaimCondition.getApprovalOpinion());
                vo.setReasonType(insuranceClaimCondition.getReasonType());
                workflowSubmitService.submit(vo);
            }

        }

        //更新保险批改信息、发起流程
        if (InsuranceBusinessTypeEnum.insuranceChange.equals(insuranceClaimCondition.getType())) {
            if (ProcessStatusEnum.draft.equals(insuranceClaimCondition.getProcessStatus())) {
                manageInsuranceBus = insuranceClaimCondition.getChangeForm();
                BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.underReview);
                updateById(insuranceClaimCondition);
                //保存合同信息变更申请记录
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                StartFlowRequest startFlowRequest = new StartFlowRequest();
                startFlowRequest.setAfsFlowKey(AfsEnumUtil.key(WorkflowTypeEnum.INSURANCE_CHANGE_EXIT));
                startFlowRequest.setBizDataId(String.valueOf(insuranceClaimCondition.getId()));
                startFlowRequest.setFlowName((StringUtils.isEmpty(insuranceClaimCondition.getContractNo()) ? "" : (insuranceClaimCondition.getContractNo()) + "-") + AfsEnumUtil.desc(WorkflowTypeEnum.INSURANCE_CHANGE_EXIT));
                JSONObject cancelJson = JSONObject.parseObject(JSONObject.toJSONString(insuranceClaimCondition));
                //保存审批记录
                TaskSubmitVO vo = new TaskSubmitVO();
                vo.setBizData(cancelJson);
                workflowSubmitService.saveRecord(vo, AfsEnumUtil.desc(NormalSubmitEnum.SUGGEST_CHECK_FINAL));

                workflowService.startWorkFlow(startFlowRequest, cancelJson);
            } else if (ProcessStatusEnum.toBeRepaired.equals(manageInsuranceInfo.getProcessStatus())) {
                manageInsuranceBus = insuranceClaimCondition.getChangeForm();
                BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.repairedUnderReview);
                updateById(insuranceClaimCondition);
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                //流程审批
                TaskSubmitVO vo = new TaskSubmitVO();
                String json = JSONObject.toJSONString(insuranceClaimCondition);
                JSONObject cancelJson = JSONObject.parseObject(json);
                vo.setBizData(cancelJson);
                vo.setApprovalOperating(insuranceClaimCondition.getApprovalOperating());
                vo.setApprovalOpinion(insuranceClaimCondition.getApprovalOpinion());
                vo.setReasonType(insuranceClaimCondition.getReasonType());
                workflowSubmitService.submit(vo);
            }

        }

        //更新保险退保信息、发起流程
        if (InsuranceBusinessTypeEnum.insuranceExit.equals(insuranceClaimCondition.getType())) {
            if (ProcessStatusEnum.draft.equals(insuranceClaimCondition.getProcessStatus())) {
                manageInsuranceBus = insuranceClaimCondition.getExitForm();
                BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.underReview);
                updateById(insuranceClaimCondition);
                //保存合同信息变更申请记录
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                StartFlowRequest startFlowRequest = new StartFlowRequest();
                startFlowRequest.setAfsFlowKey(AfsEnumUtil.key(WorkflowTypeEnum.INSURANCE_CHANGE_EXIT));
                startFlowRequest.setBizDataId(String.valueOf(insuranceClaimCondition.getId()));
                startFlowRequest.setFlowName((StringUtils.isEmpty(insuranceClaimCondition.getContractNo()) ? "" : (insuranceClaimCondition.getContractNo()) + "-") + AfsEnumUtil.desc(WorkflowTypeEnum.INSURANCE_CHANGE_EXIT));
                JSONObject cancelJson = JSONObject.parseObject(JSONObject.toJSONString(insuranceClaimCondition));
                //保存审批记录
                TaskSubmitVO vo = new TaskSubmitVO();
                vo.setBizData(cancelJson);
                workflowSubmitService.saveRecord(vo, AfsEnumUtil.desc(NormalSubmitEnum.SUGGEST_CHECK_FINAL));

                workflowService.startWorkFlow(startFlowRequest, cancelJson);
            } else if (ProcessStatusEnum.toBeRepaired.equals(insuranceClaimCondition.getProcessStatus())) {
                manageInsuranceBus = insuranceClaimCondition.getExitForm();
                BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.repairedUnderReview);
                updateById(insuranceClaimCondition);
                //保存待办任务记录
                saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                        CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
                //流程审批
                TaskSubmitVO vo = new TaskSubmitVO();
                String json = JSONObject.toJSONString(insuranceClaimCondition);
                JSONObject cancelJson = JSONObject.parseObject(json);
                vo.setBizData(cancelJson);
                vo.setApprovalOperating(insuranceClaimCondition.getApprovalOperating());
                vo.setApprovalOpinion(insuranceClaimCondition.getApprovalOpinion());
                vo.setReasonType(insuranceClaimCondition.getReasonType());
                workflowSubmitService.submit(vo);
            }

        }
    }

    @Override
    public void saveProposalApplicationInfo(ManageInsuranceInfoCondition insuranceClaimCondition) {

        ManageInsuranceInfoBusiness manageInsuranceBus = new ManageInsuranceInfoBusiness();
        //来源
        insuranceClaimCondition.setBusinessSource(null);
        //更新保险理赔信息
        if (InsuranceBusinessTypeEnum.insuranceClaim.equals(insuranceClaimCondition.getType())) {
            manageInsuranceBus = insuranceClaimCondition.getClaimForm();
            BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
            updateById(insuranceClaimCondition);
        }

        //更新保险续保信息
        if (InsuranceBusinessTypeEnum.insuranceRenew.equals(insuranceClaimCondition.getType())) {
            ManageInsuranceRenewInfo renewInfo = insuranceClaimCondition.getJson();
            String json = JSON.toJSONString(renewInfo);
            insuranceClaimCondition.setInsureType(json);
            insuranceClaimCondition.setId(insuranceClaimCondition.getId());
            updateById(insuranceClaimCondition);
        }

        //更新保险批改信息
        if (InsuranceBusinessTypeEnum.insuranceChange.equals(insuranceClaimCondition.getType())) {
            manageInsuranceBus = insuranceClaimCondition.getChangeForm();
            BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
            updateById(insuranceClaimCondition);
        }

        //更新保险退保信息
        if (InsuranceBusinessTypeEnum.insuranceExit.equals(insuranceClaimCondition.getType())) {
            manageInsuranceBus = insuranceClaimCondition.getExitForm();
            BeanUtils.copyProperties(manageInsuranceBus, insuranceClaimCondition);
            updateById(insuranceClaimCondition);
        }

        CaseStatusEnum CaseStatus;
        ProcessStatusEnum processStatus;
        //更新处理状态
        if (AfsEnumUtil.key(NormalSubmitEnum.SUGGEST_CHECK_FINAL).equals(insuranceClaimCondition.getApprovalOperating())) {
            WorkTaskCreatedInfo workTaskCreatedInfo = workTaskCreatedInfoService.getOne(Wrappers.<WorkTaskCreatedInfo>query().lambda()
                    .eq(WorkTaskCreatedInfo::getBizDataId, String.valueOf(insuranceClaimCondition.getId())));
            if (ProcessStatusEnum.approved.name().equals(workTaskCreatedInfo.getTaskMemo())) {
                insuranceClaimCondition.setEndDate(DateUtil.date());
                CaseStatus = CaseStatusEnum.APPROVED;
                processStatus = ProcessStatusEnum.approved;
            } else if (ProcessStatusEnum.repairedUnderReview.equals(insuranceClaimCondition.getProcessStatus())) {
                CaseStatus = CaseStatusEnum.UNDER_REVIEW;
                processStatus = ProcessStatusEnum.repairedUnderReview;
            } else {
                CaseStatus = CaseStatusEnum.UNDER_REVIEW;
                processStatus = ProcessStatusEnum.underReview;
            }
            insuranceClaimCondition.setProcessStatus(processStatus);

            //保存待办任务记录
            //保存合同信息变更申请记录
            saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                    CaseStatus, BusinessUrlEnum.CONTRACT_BUSINESS);
        } else if (AfsEnumUtil.key(NormalSubmitEnum.SUGGEST_REJECT_FINAL).equals(insuranceClaimCondition.getApprovalOperating())) {
            insuranceClaimCondition.setEndDate(new Date());
            insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.refuse);
            //保存合同信息变更申请记录
            saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                    CaseStatusEnum.REFUSE, BusinessUrlEnum.CONTRACT_BUSINESS);
        } else if (AfsEnumUtil.key(NormalSubmitEnum.SEND_BACK).equals(insuranceClaimCondition.getApprovalOperating())) {
            if (InsuranceBusinessTypeEnum.insuranceClaim.equals(insuranceClaimCondition.getType())) {
                WorkTaskCreatedInfo workTaskCreatedInfo = workTaskCreatedInfoService.getOne(Wrappers.<WorkTaskCreatedInfo>query().lambda()
                        .eq(WorkTaskCreatedInfo::getBizDataId, String.valueOf(insuranceClaimCondition.getId())));
                if (ProcessStatusEnum.toBeRepaired.name().equals(workTaskCreatedInfo.getTaskMemo()) || ProcessStatusEnum.approved.name().equals(workTaskCreatedInfo.getTaskMemo())) {
                    insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.toBeRepaired);
                }
            } else {
                insuranceClaimCondition.setProcessStatus(ProcessStatusEnum.toBeRepaired);
            }

            //保存待办任务记录
            saveApproveInfoProcessor.saveApproveInfo(insuranceClaimCondition, ContractBusinessEnum.insurance,
                    CaseStatusEnum.UNDER_REVIEW, BusinessUrlEnum.CONTRACT_BUSINESS);
        }
        //流程审批
        TaskSubmitVO vo = new TaskSubmitVO();
        String json = JSONObject.toJSONString(insuranceClaimCondition);
        JSONObject cancelJson = JSONObject.parseObject(json);
        vo.setBizData(cancelJson);
        vo.setApprovalOperating(insuranceClaimCondition.getApprovalOperating());
        vo.setApprovalOpinion(insuranceClaimCondition.getApprovalOpinion());
        vo.setReasonType(insuranceClaimCondition.getReasonType());
        workflowSubmitService.submit(vo);
        updateById(insuranceClaimCondition);
    }

    @Override
    public IPage<ManageInsuranceInfo> getInsuranceInfoList(Page page, ManageInsuranceInfoCondition condition) {
        return this.baseMapper.getInsuranceInfoList(page, condition);
    }

    @Override
    public IPage<ManageInsuranceInfo> insuranceInfoList(Page page, ManageInsuranceInfoCondition condition) {
        return this.baseMapper.insuranceInfoList(page, condition);
    }
}
